﻿using XLua;
using UnityEngine;

namespace Kylin
{
    public class CSharpCallLuaDelegates : Singleton<CSharpCallLuaDelegates>
    {
        [CSharpCallLua]
        public interface ILuaGameManager
        {
            void init();

            void update(float deltaTime);

            void fixedUpdate(float fixedDeltaTime);

            void onDestroy();
        }

        [CSharpCallLua]
        public interface ILuaNetwork
        {
            void onReceiveMsg(int msgId, byte[] content);
        }
        
        public ILuaGameManager LuaGameManagerEntry { get; private set; }
        public ILuaNetwork LuaNetworkEntry { get; private set; }

        public void Initialize()
        {
            LuaManager.Instance.DoFile("Main");

            LuaGameManagerEntry = LuaManager.Instance.BindToLua<ILuaGameManager>("GameManager");
            LuaNetworkEntry = LuaManager.Instance.BindToLua<ILuaNetwork>("NetworkManager");
        }
    }
}